package sqlTest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.util.Vector;

public class sqlTest {

	public static void main(String[] args) {		
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@cmgcdb02:1521:cmctst","dbakm","kmdba");
			Statement s = conn.createStatement();
			String sql="select a.emp_no,a.emp_name, b.dept_name from cmc_employee a,cmc_department b where a.emp_unit=b.dept_no and trim(b.invalid_date) is null and trim(a.emp_leave_date)is null and a.dept_level1='A124' order by dept_name,emp_no";
			ResultSet rs=s.executeQuery(sql);
			
			while(rs.next())
			{
				System.out.println(rs.getString(1)+"\t");
				System.out.println(rs.getString(2)+"\t");
				System.out.println(rs.getString(3)+"\t");
			}
			
			s.close();
			conn.close();
				
		}catch(Exception e){
			System.out.println(e.toString());				
		}
	}

}
